<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Session;
class indexController extends Controller
{
    public function index($pid = 0)
    {

        // $cateData = DB::table('types') -> where('pid', $pid) -> get();
        
        // $data = [];
        // foreach ($cateData as $key => $value) {
        //     $value -> sub = $this -> index($value -> tid);
        //     $data[] = $value;
        // }
        // Session::put('public',$cateData);

        //头部公共部分
        $public = DB::table('types') -> where('pid','0')->get();
        Session::put('public',$public);
        //首页部分
        $data = DB::table('goods')->where('status','1')->get();
        $new = DB::table('goods')->where('scnt','>=','100')->get();
        //精选系列
        $wtid = 2;
        
        $women = DB::table('goods')
                ->leftJoin('types','goods.tid','=','types.tid') 
                ->where('path','like','%'.$wtid.'%')
                ->where('scnt','>','300')
                ->first();
        $men = 1;
        $men = DB::table('goods')
                ->leftJoin('types','goods.tid','=','types.tid') 
                ->where('path','like','%'.$men.'%')
                ->where('scnt','=','300')
                ->first();
        $shoe = 3;
        $shoe = DB::table('goods')
                ->leftJoin('types','goods.tid','=','types.tid') 
                ->where('path','like','%'.$shoe.'%')
                ->where('scnt','=','300')
                ->first();
        $case = 12;
        $case = DB::table('goods')
                ->leftJoin('types','goods.tid','=','types.tid') 
                ->where('path','like','%'.$case.'%')
                ->where('scnt','=','300')
                ->first();
        // dd($women);
        return view('home.index.index',['data'=>$data,'title'=>'首页','new'=>$new,'women'=>$women,'men'=>$men,'shoe'=>$shoe,'case'=>$case]);
    }
}
